<?php
class Attr_groupAttr extends BaseAttr {
	public function Attr_groupAttr($attr, $lang=null, $mutil_lang=false){
		parent::BaseAttr($attr, $lang, $mutil_lang);
	}
	
	protected function init_data(){
		$attr_mod = new AttrsModel();
		$attrs = $attr_mod->find(array('$or'=>array(
			array('site_id'=>SITE_ID),
			array('owner'=>'system'),
		)), 'name');
		lang_fatch($attrs, LANGUAGE);
		$tree = new Tree($attrs);
		$options = $tree->get_options('　');
		return array(
			'options' => $options
		);
	}
	

	public function get_post_val(&$getted_post_data){
		$id = $this->attr['id'];
		$attr_groups = $_POST[$id];
		foreach($attr_groups as $k=>$v){
			if($v === '0'){
				unset($attr_groups[$k]);
			}
		}
		reset($attr_groups);
		if(count($attr_groups)>0){
			$getted_post_data[$id] = $attr_groups;
		}else{
			if($this->attr['required']){
				$this->error = $this->attr['name'] . Lang::get('not_null');
			}
		}
	}
}

?>